/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gitlab.bootren.data.core.query;

import com.gitlab.bootren.data.core.query.restriction.RestrictionType;

import java.util.Map;

/**
 *
 * 对外调用唯一API
 * @author tengda
 */
public class Condition implements ICondition{

    private ICondition  target = new EmptyCondition();
    
    public static Condition  createEmpty(){
        return new Condition();
    }
    public static Condition  createKeyValue(String key, Object value){
        return new Condition().and(key, value);
    }
   
    public static Condition  createJpql(String jpql){
        return new Condition().and(jpql);
    }
    

    @Override
    public Condition setParam(String paramName, Object object) {
        target = target.setParam(paramName, object);
        return this;
        
    }

    @Override
    public Condition and(ICondition conditionModel) {
        target = target.and(conditionModel);
        return this;
    }

    @Override
    public Condition and(String key, Object value) {
        target = target.and(key, value);
        return this;
    }

    @Override
    public Condition and(String key, Object value, RestrictionType restrictionType) {
        target = target.and(key, value, restrictionType);
         return this;
    }

    @Override
    public Condition and(String jpql) {
        target = target.and(jpql);
         return this;
    }

    @Override
    public Condition or(ICondition conditionModel) {
        target = target.or(conditionModel);
         return this;
    }

    @Override
    public Condition or(String key, Object value) {
        target = target.or(key, value);
         return this;
    }

    @Override
    public Condition or(String key, Object value, RestrictionType restrictionType) {
        target = target.or(key, value, restrictionType);
         return this;
    }

    @Override
    public Condition or(String jpql) {
        target = target.or(jpql);
         return this;
    }

    @Override
    public Condition setParams(Map<String, Object> params) {
        target = target.setParams(params);
         return this;
    }

    @Override
    public Map<String, Object> getParams() {
         return target.getParams();
    }


    @Override
    public String toQl() {
        return target.toQl();
    }

    @Override
    public String toQl(String aliasName) {
        return target.toQl(aliasName);
    }
 
   
    
}
